package Dr;

import java.util.Scanner;

class ArrayUtils{
	public static double findMax(double[] arr,int begin, int end) throws IllegalArgumentException{
		if(begin >= end)
			throw new IllegalArgumentException("begin:"+begin+" >= end:"+end);
		if(begin < 0)
		    throw new IllegalArgumentException("begin:"+begin+" < 0");
		if(end > arr.length)
			throw new IllegalArgumentException("end:"+end+" > arr.length");
		
		double maxValue = arr[begin]; 
		for(int i = begin;i < end;i++){
			if(arr[i] >= maxValue)
				maxValue = arr[i];						
		}				
		return maxValue;		
	}
}

public class Main {

	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] arr = new double[n];
		
		
		for(int i = 0;i < n;i++){
			 String inputInt = sc.next();
			arr[i] = Double.parseDouble(inputInt);
			
		}
		while(sc.hasNextInt()){
		    try{
	    	System.out.println(ArrayUtils.findMax(arr,sc.nextInt(), sc.nextInt()));
		    }catch(NumberFormatException e){
				break;
			}catch(IllegalArgumentException e2){
		    	System.out.println(e2);
		    	
		    }
		    
		}
		try {
		     System.out.println(ArrayUtils.class.getDeclaredMethod("findMax", double[].class,int.class,int.class));
		} catch (Exception e1) {
		}
	}

}
